package com.freshmarket.freshmarket.controller;


import com.freshmarket.freshmarket.entity.UserCoupon;
import com.freshmarket.freshmarket.service.IUserCouponService;
import com.freshmarket.freshmarket.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@RestController
@RequestMapping("/freshmarket/user-coupon")
@Slf4j
public class UserCouponController {
    @Autowired
    private IUserCouponService iUserCouponService;

    //新增直接发放券
    @RequestMapping("insertDirect")
    @ResponseBody
    public Result insertDirect(@RequestBody UserCoupon userCoupon) throws Exception {
        log.info("当前id:{}"+userCoupon.getUserId());
        Result result = iUserCouponService.insertDirect(userCoupon);

        return result;
    }

    /**
     * 新增:用户领取积分兑换券insertScore
     */
    @RequestMapping("insertScore")
    @ResponseBody
    public Result insertScore(@RequestBody UserCoupon userCoupon) throws Exception {

        Result result = iUserCouponService.insertScore(userCoupon);

        return result;
    }



}

